﻿<?php


//header ("Content-type: application/vnd.ms-execl");
//header('Content-Disposition:attachment;filename="'.'重复数据'.date("Ymd").'.xls'.'"');


importTellNotShenFeng($_GET['starTime'],$_GET['endTime'],$_GET['shengFeng']);

function importTellNotShenFeng($starTime,$endTime,$shengFeng){




	$qure="select * from chongfuTell WHERE riqi BETWEEN '{$starTime}' AND '{$endTime}'";

	$host='localhost';
	$user='root';
	$password='root';
	$database='weizandata';
	$link=mysqli_connect($host, $user, $password, $database);
	$link->query("set names utf8");
	$result=mysqli_query($link, $qure);
	$arr=mysqli_fetch_all($result, 1);

	mysqli_close($link);


	//var_dump($arr);

	require_once 'PHPExcel-1.8/Classes/PHPExcel.php';

	$excelFiled=array('手机号码','省份','城市','日期');

	$dataArray=$arr;

	$objPHPExcel=new PHPExcel();

	$objPHPExcel->getActiveSheet()->fromArray($excelFiled,'A1');

	$row=1;

		for ($j=0; $j <count($dataArray) ; $j++) { 
			
			 $City=$dataArray[$j]['city'];

			 $shengFeng1=$dataArray[$j]['shengFen'];

			 $tell=$dataArray[$j]['tell'];

			 $riqi=$dataArray[$j]['riqi'];

			 	$row+=1;

			 	$objPHPExcel->getActiveSheet()->setCellValue('A'.$row, $tell);

			 	$objPHPExcel->getActiveSheet()->setCellValue('B'.$row, $shengFeng1);

			 	$objPHPExcel->getActiveSheet()->setCellValue('C'.$row, $City);

			 	$objPHPExcel->getActiveSheet()->setCellValue('D'.$row, $riqi);


		}


		$objWriter =PHPExcel_IOFactory:: createWriter($objPHPExcel, 'Excel2007');

		$nameFile='重复数据'.date("Ymd");

		$objWriter->save("excel/{$nameFile}.xlsx");  //  php://output

	// // header('Content-Type: application/vnd.ms-excel');
	// // header('Content-Disposition: attachment;filename="excel/'.$nameFile.'.xlsx"');
	// // header('Cache-Control: max-age=0');

	// // $dat=$shengFeng.date('Ymd');

		
	// $filename="excel/{$nameFile}.xlsx";
	// header("Cache-Control: public"); 
	// header("Content-Description: File Transfer"); 
	// header('Content-disposition: attachment; filename='.basename($filename)); //文件名  
	// header("Content-Type: application/vnd.ms-excel"); //zip格式的  
	// header("Content-Transfer-Encoding: binary"); //告诉浏览器，这是二进制文件  
	// header('Content-Length: '. filesize($filename)); //告诉浏览器，文件大小  
	// @readfile($filename);

}

	header("Content-type: text/html; charset=utf-8");

	header("Location: excel/重复数据".date('Ymd').".xlsx");

?>
